linearregression class
Simple Linear Regression
Linear regression is an algorithm used to predict or visualise a relationship between two different features/variables. In linear regression tasks, there are two kinds of variables being examined: the dependent variable and the independent variable. Let us build our first Simple Linear Regression Model and learn along the way by building. This particular model is called as simple because it has only one independent variable. Here we are using the data containing people's salary and working experience to predict someone's salary based on their experience.
How to implement Linear Regression with TensorFlow
Now, let's jump to the implementation. Firstly, we need to, obviously, import some libraries. We import tensorflow as it is the main thing we use for the implementation, matplotlib for visualizing our results, make_regression function, from sklearn, which we will be using to generate a regression dataset for using as an example, and the python's built-in math module. The first thing we do inside .fit() is to concatenate an extra column of 1's to our input matrix X. This is to simplify our math and treat the bias as the weight of an extra variable that's always 1.